While it is generally terrible to silently ignore errors in the
configuration files, it is acceptable in this case. Verbosity and color
config have reasonable defaults, and we don't want to fail for simple
commands like `cargo --version` just because of the garbage in the
config file.
fixed #2848
locked: bool) -> CargoResult<()> {
let extra_verbose = verbose >= 2;
let verbose = if verbose == 0 {None} else {Some(true)};
- let cfg_verbose = try!(self.get_bool("term.verbose")).map(|v| v.val);
- let cfg_color = try!(self.get_string("term.color")).map(|v| v.val);
+
+ // Ignore errors in the configuration files.
+ let cfg_verbose = self.get_bool("term.verbose").unwrap_or(None).map(|v| v.val);
+ let cfg_color = self.get_string("term.color").unwrap_or(None).map(|v| v.val);
+
let color = color.as_ref().or(cfg_color.as_ref());
let verbosity = match (verbose, cfg_verbose, quiet) {
assert_that(p.cargo_process("version").env("PATH", ""),
execs().with_status(0));
}
+
+#[test]
+fn version_works_with_bad_config() {
+ let p = project("foo")
+ .file(".cargo/config", "this is not toml");
+ assert_that(p.cargo_process("version"),
+ execs().with_status(0));
+}
+
+#[test]
+fn version_works_with_bad_target_dir() {
+ let p = project("foo")
+ .file(".cargo/config", r#"
+ [build]
+ target-dir = 4
+ "#);
+ assert_that(p.cargo_process("version"),
+ execs().with_status(0));
+}